/*
 * //Author: Karthic Kumar Sekar [A0092622]
 */

package sg.edu.nus.iss.team4ft.service;
import java.io.IOException;
import java.io.Serializable;
import java.util.Date;

import sg.edu.nus.iss.team4ft.exception.InvalidOperationException;
import sg.edu.nus.iss.team4ft.util.AppConstant;

public class DigitalVoice extends VoicePlan  implements Serializable {

	private static final long serialVersionUID = 1L;

	protected DigitalVoice(DigitalVoice digitalVoice) {
		super(digitalVoice);
	}
	
	public DigitalVoice(Date startDate) throws InvalidOperationException, IOException, ClassNotFoundException{
		super(startDate,PlanCode.DigitalVoice);

		super.setServiceName(AppConstant.DIGITAL_VOICE_PLAN);
	}
	
	@Override
	public void subscripeNewFeature(Feature feature)
			throws InvalidOperationException {
		//DigitalVoice will allow only feature of following type
		if(feature.getFeatureCode() == FeatureCode.LocalCall ||
				feature.getFeatureCode() == FeatureCode.InternationalCall ||
				feature.getFeatureCode() == FeatureCode.CallTransfer)
			super.subscripeNewFeature(feature);
		else
			throw new InvalidOperationException("Feature '" + feature.getFeatureCode().toString() + "' cannot be added to plan'"+ this.getPlanCode().toString() + "'");
	}

	@Override
	public DigitalVoice clone() throws CloneNotSupportedException {
		DigitalVoice d = new DigitalVoice(this);
		return d;
	}
}

